import axios from 'axios'

export function getProduct (id) {
  return axios.get(`api/products/${id}`)
}

export function getUser () {
  return axios.get('api/user')
}

export function register (params) {
  return axios.post(`api/user/register`, params)
}

export function UserLogin (params) {
  return axios.post(`api/user/login`, params)
}

export function Logout () {
  return axios.post(`api/user/logout`)
}

export function getCart () {
  return axios.get('api/carts')
}

export function addCart (params) {
  return axios.post('api/carts', params)
}

export function updata (id, params) {
  return axios.put(`api/carts/${id}`, params)
}

export function selectAll () {
  return axios.put(`api/carts/selectAll`)
}

export function unSelectAll () {
  return axios.put(`api/carts/unSelectAll`)
}

export function deleteProduct (id) {
  return axios.delete(`api/carts/${id}`)
}

export function getCartSum () {
  return axios.get(`api/carts/products/sum`)
}

/*
*
* 收获地址接口api
* */

export function getAddressList () {
  return axios.get(`api/shippings`)
}

export function deleteAddress (id) {
  return axios.delete(`api/shippings/${id}`)
}

export function addAddress (params) {
  return axios.post(`api/shippings`, params)
}

export function editAddress (id, params) {
  return axios.put(`api/shippings/${id}`, params)
}

/*
* 城市接口
*
* */

export function getProvince () {
  return axios.get('http://rap2.taobao.org:38080/app/mock/258620/api/v1/region/province')
}

export function getCity (id) {
  return axios.get('http://rap2.taobao.org:38080/app/mock/258620/api/v1/region/city', id)
}

export function getCounty (id) {
  return axios.get('http://rap2.taobao.org:38080/app/mock/258620/api/v1/region/county', id)
}

/**
 * 订单接口
 */
export function createOrder (shippingId) {
  return axios.post('api/orders', shippingId)
}

export function getOrderDetail (id) {
  return axios.get(`api/orders/${id}`)
}

export function aliPay (params) {
  return axios.post('api/pay', params)
}

export function wxPay (params) {
  return axios.post('api/pay', params)
}
